<template>
  <div>
    <el-input v-model="sid" placeholder="请输入学号"></el-input>
    <el-button type="primary" @click="search">查询课程</el-button>
    <el-table :data="tableData" border stripe width="100%">
      <el-table-column prop="sid" label="学号"></el-table-column>
      <el-table-column prop="cid" label="课程号"></el-table-column>
      <el-table-column prop="tid" label="教工号"></el-table-column>
      <el-table-column prop="score" label="成绩"></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" @click="changeCourse(scope.row.sid, scope.row.cid)">更新</el-button>
          <el-button size="mini" type="danger" @click="remove(scope.row.sid, scope.row.cid)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import {getMyCourse} from '@/http/api/student'

export default {
  name: "Experiment5",
  data() {
    return {
      sid: '',
      tableData: []
    }
  },
  methods: {
    async search(){
      if (this.sid === '') {
        return
      }
      let res = await getMyCourse(this.sid)
      if (res.code === 0) {
        this.$message.success(res.message)
        this.tableData = res.data
      }else{
        this.$message.warning(res.message)
      }
    },
    changeCourse() {
      this.$message.success("更新课程")
    },
    remove(){
      this.$message.success("删除成功")
    }
  }
}
</script>

<style scoped>

</style>